% ************************************************************************ 
%     Module name   : Lynx Simulation - Track Mode Run                                                     
%                                                                          
%     Description   : This will run the Track mode on a specific target.                                                    
%                                                                          
%     $Header: /Lynx/SimulationFramework/RSP/IFS/IFSRun.m 2     15/10/08 16:08 Lwabeke $ 
%                                                                          
%    $Author: Lwabeke $	            
%                                                                         
%    $Revision: 2 $                
%                                                                         
% ************************************************************************
%     $History: IFSRun.m $ 
% 
%
% ************************************************************************
function old_state_estimate = state_estimate_search(time, radarState)

    %sector = floor((radarState.searchSetup.chosen_action-1)/3) + 1; % 1 based indexing
    sector = radarState.searchSetup.sector;
    delta_time = time - radarState.search.time_NCI(sector);
    if ( delta_time < 0.4)
        NCI_state = 0;
    elseif ( delta_time < 1.1)
        NCI_state = 1;
    else    
        NCI_state = 2;
    end

    delta_time = time - radarState.search.time_MTI(sector);
    if ( delta_time < 0.4)
        MTI_state = 0;
    elseif ( delta_time < 1.1)
        MTI_state = 1;
    else    
        MTI_state = 2;
    end

    delta_time = time - radarState.search.time_Stationary(sector);
    if ( delta_time < 0.4)
        Stationary_state = 0;
    elseif ( delta_time < 1.1)
        Stationary_state = 1;
    else    
        Stationary_state = 2;
    end
    
    old_state_estimate = (sector-1)*3^3 + NCI_state*3^2 + MTI_state * 3 + Stationary_state    +1;
    
